﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.Revit;
using YRevitJig;

namespace YArchitech.HVAC
{
	public class LayRadiatorDrawJin : XUiJigBase
	{
		public XYZ StartPoint { get; set; }

		public LayRadiatorDrawJin(UIDocument uiDoc, bool freeLay) : base(uiDoc)
		{
			this.freeLay = freeLay;
		}

		public override void Draw(PaintEventArgs paintEventArgs)
		{
			base.Draw(paintEventArgs);
			if (!this.m_ptCur.IsEmpty && paintEventArgs != null)
			{
				try
				{
					XYZ xyz = base.Client2Revit(this.m_ptCur);
					XYZ currentPoint = new XYZ(xyz.X, xyz.Y, this.StartPoint.Z);
					this.resultLines = LayRadiatorDrawUtility.Draw(base.Doc.ActiveView, this.StartPoint, currentPoint, this.freeLay);
					XGraphics g = new XGraphics(paintEventArgs.Graphics, base.JigPen);
					foreach (Line curve in this.resultLines)
					{
						new XLine2D(base.Revit2Client(curve.GetEndPoint(0)), base.Revit2Client(curve.GetEndPoint(1))).Draw(g);
					}
				}
				catch (Exception ex)
				{
					ex.ToString();
				}
			}
		}

		public List<Line> resultLines = new List<Line>();

		private bool freeLay = true;
	}
}
